package com.rota.service.impl;

import java.util.Date;

import com.rota.domain.UserInfo;
import com.rota.mapper.UserInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.rota.service.IUserInfoService;

@Service
public class UserInfoServiceImpl implements IUserInfoService{

	@Autowired
	private UserInfoMapper userInfoMapper;
	
	@Override
	public UserInfo getUserInfoByOpenId(String openId) {
		// TODO Auto-generated method stub
		return userInfoMapper.getUserInfoByOpenId(openId);
	}

	@Override
	public UserInfo getUserInfoByUsername(String username) {
		return userInfoMapper.getUserInfoByUsername(username);
	}

	@Override
	public UserInfo findUser(String username, String password) {
		return userInfoMapper.findUser(username,password);
	}


	@Override
	public void save(UserInfo userInfo) {
		// TODO Auto-generated method stub
		if(userInfo.getId() == null) {
			userInfo.setRegisttime(new Date());
			userInfo.setState(new Byte("1"));
			userInfoMapper.insert(userInfo);
		}else {
			userInfoMapper.updateByPrimaryKey(userInfo);
		}
		
	}

}
